<?php
namespace TeamPlayers;

/**
 * 
 * Saves and provides settings for the site. Also holds controllers for adding/moving/deleting players, teams and divisions. 
 * @author martin
 *
 */
class settingsController extends baseController{
	
	function __construct(){
		
	if(TeamPlayers::$ac->hasRole('SystemAdministrator')){
			
			if(empty($_GET['method'])){
				TeamPlayers::$smarty->display("settings/siteSettings.tpl");
			} else {
				if(method_exists($this, strtolower($_GET['method']))){
				call_user_func(array($this, strtolower($_GET['method'])));
				} else {
					$this->display404();
				}
			}
			
		} else {
			TeamPlayers::$smarty->assign("message", "You need the administrator role in order to access this page.");
			TeamPlayers::$smarty->display("genericMessages/noAccess.tpl");
		}
		
		
	}
	
	/**
	 * 
	 * Sends a json-formatted string of the general settings.
	 */
	public function getGeneralSettings(){
		TeamPlayers::$axt->echoJson(TeamPlayers::$settings);
	}
	
	public function updateGeneralSettings(){
		
	}
	
	public function updateDivisonSettings(){
		
	}
	
	public function updateTeamSettings(){
		
	}
	
	public function updatePlayerSettings(){
		
	}
	
	public function addPlayerToTeam(){
		
	}
}